package com.itheima.review.controller.v1;

import com.itheima.model.common.dtos.ResponseResult;
import com.itheima.model.review.dtos.ReviewDto;
import com.itheima.review.service.impl.ReviewServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1")
@Api(value = "书评相关的接口",tags = "书评相关的接口")
public class ReviewController {
    @Autowired
    private ReviewServiceImpl reviewService;

    /**
     * 获取书评列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("获取书评列表")
    public ResponseResult getReviewList(@RequestBody ReviewDto dto){
        return reviewService.getReviewList(dto);
    }
    /**
     * 新增书评
     * @param dto
     * @return
     */
    @PostMapping()
    @ApiOperation("新增书评")
    public ResponseResult addReview(@RequestBody ReviewDto dto){
        return reviewService.addReview(dto);
    }
    /**
     * 修改书评
     * @param dto
     * @return
     */
    @PutMapping()
    @ApiOperation("修改书评")
    public ResponseResult updateReview(@RequestBody ReviewDto dto){
        return reviewService.updateReview(dto);
    }
    /**
     * 删除书评
     */
    @DeleteMapping("/{id}")
    @ApiOperation("删除书评")
    public ResponseResult deleteReview(@PathVariable String id){
        return reviewService.deleteReview(id);
    }
    
    /**
     * 根据ID获取书评详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("根据ID获取书评详情")
    public ResponseResult getReviewById(@PathVariable String id){
        return reviewService.getReviewById(id);
    }
}
